/**
 *
 */
import Util;
import OpenApi;
import OpenApiUtil;
import EndpointUtil;

extends OpenApi;


init(config: OpenApi.Config){
  super(config);
  @endpointRule = 'regional';
  
  checkConfig(config);
  @endpoint = getEndpoint('nlp-automl', @regionId, @endpointRule, @network, @suffix, @endpointMap, @endpoint);
}

function getEndpoint(productId: string, regionId: string, endpointRule: string, network: string, suffix: string, endpointMap: map[string]string, endpoint: string) throws: string{
  if (!Util.empty(endpoint)) {
    return endpoint;
  }
  
  if (!Util.isUnset(endpointMap) && !Util.empty(endpointMap[regionId])) {
    return endpointMap[regionId];
  }
  return EndpointUtil.getEndpointRules(productId, regionId, endpointRule, network, suffix);
}

model AddMTInterveneWordRequest {
  packageId?: string(name='PackageId', example='1'),
  projectId?: string(name='ProjectId', description='This parameter is required.', example='1'),
  sourceText?: string(name='SourceText', description='This parameter is required.', example='hello'),
  targetText?: string(name='TargetText'),
}

model AddMTInterveneWordResponseBody = {
  code?: int32(name='Code', example='200'),
  message?: string(name='Message', example='parameterError'),
  requestId?: string(name='RequestId', example='46E6B40D-2B6C-571B-AC41-86207DE288A5'),
  wordId?: long(name='WordId', example='1'),
}

model AddMTInterveneWordResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: AddMTInterveneWordResponseBody(name='body'),
}

/**
 * @param request AddMTInterveneWordRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return AddMTInterveneWordResponse
 */
async function addMTInterveneWordWithOptions(request: AddMTInterveneWordRequest, runtime: Util.RuntimeOptions): AddMTInterveneWordResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.packageId)) {
    query['PackageId'] = request.packageId;
  }
  if (!Util.isUnset(request.projectId)) {
    query['ProjectId'] = request.projectId;
  }
  if (!Util.isUnset(request.sourceText)) {
    query['SourceText'] = request.sourceText;
  }
  if (!Util.isUnset(request.targetText)) {
    query['TargetText'] = request.targetText;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'AddMTInterveneWord',
    version = '2019-07-01',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

/**
 * @param request AddMTInterveneWordRequest
 * @return AddMTInterveneWordResponse
 */
async function addMTInterveneWord(request: AddMTInterveneWordRequest): AddMTInterveneWordResponse {
  var runtime = new Util.RuntimeOptions{};
  return addMTInterveneWordWithOptions(request, runtime);
}

model GetPredictDocRequest {
  docId?: long(name='DocId', description='This parameter is required.', example='1000'),
  product?: string(name='Product'),
}

model GetPredictDocResponseBody = {
  requestId?: string(name='RequestId', example='86D18195-D89C-4C8C-9DC4-5FCE789CE6D5'),
  resultContent?: string(name='ResultContent', example='xxx'),
  status?: int32(name='Status', example='2'),
  XLIFFInfo?: string(name='XLIFFInfo', example='xxx'),
}

model GetPredictDocResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: GetPredictDocResponseBody(name='body'),
}

/**
 * @param request GetPredictDocRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return GetPredictDocResponse
 */
async function getPredictDocWithOptions(request: GetPredictDocRequest, runtime: Util.RuntimeOptions): GetPredictDocResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.docId)) {
    query['DocId'] = request.docId;
  }
  if (!Util.isUnset(request.product)) {
    query['Product'] = request.product;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'GetPredictDoc',
    version = '2019-07-01',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

/**
 * @param request GetPredictDocRequest
 * @return GetPredictDocResponse
 */
async function getPredictDoc(request: GetPredictDocRequest): GetPredictDocResponse {
  var runtime = new Util.RuntimeOptions{};
  return getPredictDocWithOptions(request, runtime);
}

model PredictMTModelByDocRequest {
  fileContent?: string(name='FileContent', description='This parameter is required.', example='[base64 encode content]'),
  fileType?: string(name='FileType', description='This parameter is required.', example='docx'),
  modelId?: int32(name='ModelId', description='This parameter is required.', example='1'),
  modelVersion?: string(name='ModelVersion', description='This parameter is required.', example='v1'),
  needXLIFF?: boolean(name='NeedXLIFF', example='true'),
}

model PredictMTModelByDocResponseBody = {
  docId?: string(name='DocId', example='1'),
  requestId?: string(name='RequestId', example='86D18195-D89C-4C8C-9DC4-5FCE789CE6D5'),
}

model PredictMTModelByDocResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: PredictMTModelByDocResponseBody(name='body'),
}

/**
 * @param request PredictMTModelByDocRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return PredictMTModelByDocResponse
 */
async function predictMTModelByDocWithOptions(request: PredictMTModelByDocRequest, runtime: Util.RuntimeOptions): PredictMTModelByDocResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.fileType)) {
    query['FileType'] = request.fileType;
  }
  if (!Util.isUnset(request.modelId)) {
    query['ModelId'] = request.modelId;
  }
  if (!Util.isUnset(request.modelVersion)) {
    query['ModelVersion'] = request.modelVersion;
  }
  if (!Util.isUnset(request.needXLIFF)) {
    query['NeedXLIFF'] = request.needXLIFF;
  }
  var body : map[string]any = {};
  if (!Util.isUnset(request.fileContent)) {
    body['FileContent'] = request.fileContent;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
    body = OpenApiUtil.parseToMap(body),
  };
  var params = new OpenApi.Params{
    action = 'PredictMTModelByDoc',
    version = '2019-07-01',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

/**
 * @param request PredictMTModelByDocRequest
 * @return PredictMTModelByDocResponse
 */
async function predictMTModelByDoc(request: PredictMTModelByDocRequest): PredictMTModelByDocResponse {
  var runtime = new Util.RuntimeOptions{};
  return predictMTModelByDocWithOptions(request, runtime);
}

